Ext.setup({
    tabletStartupScreen: 'tablet_startup.png',
    phoneStartupScreen: 'phone_startup.png',
    icon: 'icon.png',
    glossOnIcon: false,
    onReady : function() {
        Ext.regModel('Contact', {
            fields: ['BILLCODE', 'AMOUNT','DEPARTMENT']
        });

        var groupingBase = {
            itemTpl: '<div class="contact2"><strong>{BILLCODE}</strong> {DEPARTMENT}</div>',
            grouped: true,
            indexBar: false,

            onItemDisclosure: {
                scope: 'test',
                handler: function(record, btn, index) {
                    console.log('Disclose more info for ' + record.get('BILLCODE'));
                    window.location.href='../../costmanagement/dailyCostSubmit/editdailyCostSubmit.jsp?param=001,'+record.get('BILLCODE');
                }
            },

            store: new Ext.data.Store({
                model: 'Contact',
                sorters: 'BILLCODE',
                autoLoad: true,
                getGroupString : function(record) {
                    return record.get('BILLCODE')[0];
                },
                proxy:{
                    type:'ajax',
                    url:'../../costmanagement/dailyCostSubmit/dailyListCost_getDailyList.action',
                    reader:{
                        type:'json',
                        root:'getDailyList'
                    },
                },
            })
        };

        var App = new Ext.Application({
            name: 'NotesApp',
            useLoadMask: true,
            launch: function () {

                NotesApp.views.notesListToolbar = new Ext.Toolbar({
                    id: 'notesListToolbar',
                    title: '日常费用报销',
                    items: [
                            {xtype: 'spacer'},
                            {
                            	iconMask: true,
                            	iconCls: 'add',
                            	handler:function () {
                            		window.location.href='../../costmanagement/dailyCostSubmit/dailyCostSubmit.jsp';
                            	}
                            }
                    ]
                });
                
                NotesApp.views.notesList =  new Ext.List(Ext.apply(groupingBase, {
                    fullscreen: true
                }));
                
                NotesApp.views.notesListContainer = new Ext.Panel({
                    id: 'notesListContainer',
                    layout: 'fit',
                    dockedItems: [NotesApp.views.notesListToolbar,NotesApp.views.notesList]
                });

                NotesApp.views.viewport = new Ext.Panel({
                    fullscreen: true,
                    layout: 'card',
                    cardAnimation: 'slide',
                    items: [NotesApp.views.notesListContainer]
                });
            }
        });
        
    }
});
